﻿using System.Data;

namespace DAL
{
    public static class DalUserPermisstion
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetUserPermisstion(string keywords,int groupUser)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            Cls.AddParameter("@Group_Id", groupUser);
            return Cls.GetData("sp_UserPermisstion_Get");
        }
        public static DataTable GetUserPermisstionAll(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_UserPermisstion_GetAll");
        }
        public static DataTable GetUserPermisstionEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", id);
            return Cls.GetData("sp_UserPermisstion_Get_Edit");
        }
        public static DataTable GetUserPermisstionFillter(string modulesMainId, string modulesParrentId, string groupUser)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ModulesMain_ID", modulesMainId);
            Cls.AddParameter("@ModulesParent_ID", modulesParrentId);
            Cls.AddParameter("@Group_Id", groupUser);
            return Cls.GetData("sp_UserPermisstion_Get_Fillter");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtUserPermisstion obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ModulesMain_ID", obj.ModulesMainId);
            Cls.AddParameter("@ModulesParent_ID", obj.ModulesParentId);
            Cls.AddParameter("@Group_Id", obj.GroupId);
            Cls.AddParameter("@PermisstionNumber", obj.PermisstionNumber);
            Cls.AddParameter("@IsbtnView", obj.IsbtnView);
            Cls.AddParameter("@IsbtnAddNew", obj.IsbtnAddNew);
            Cls.AddParameter("@IsbtnEdit", obj.IsbtnEdit);
            Cls.AddParameter("@IsbtnDelete", obj.IsbtnDelete);
            Cls.AddParameter("@IsbtnReview", obj.IsbtnReview);
            Cls.AddParameter("@IsbtnCancel", obj.IsbtnCancel);
            Cls.AddParameter("@IsbtnPrint", obj.IsbtnPrint);
            Cls.AddParameter("@IsPageMain", obj.IsPageMain);
            Cls.AddParameter("@IsPageParrent", obj.IsPageParrent);
            Cls.AddParameter("@Descripttion", obj.Descripttion);
            return Cls.ExecuteNonQuery("sp_UserPermisstion_Insert");
        }
        public static bool Update(EtUserPermisstion obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", obj.Id);
            Cls.AddParameter("@ModulesMain_ID", obj.ModulesMainId);
            Cls.AddParameter("@ModulesParent_ID", obj.ModulesParentId);
            Cls.AddParameter("@Group_Id", obj.GroupId);
            Cls.AddParameter("@PermisstionNumber", obj.PermisstionNumber);
            Cls.AddParameter("@IsbtnView", obj.IsbtnView);
            Cls.AddParameter("@IsbtnAddNew", obj.IsbtnAddNew);
            Cls.AddParameter("@IsbtnEdit", obj.IsbtnEdit);
            Cls.AddParameter("@IsbtnDelete", obj.IsbtnDelete);
            Cls.AddParameter("@IsbtnReview", obj.IsbtnReview);
            Cls.AddParameter("@IsbtnCancel", obj.IsbtnCancel);
            Cls.AddParameter("@IsbtnPrint", obj.IsbtnPrint);
            Cls.AddParameter("@IsPageMain", obj.IsPageMain);
            Cls.AddParameter("@IsPageParrent", obj.IsPageParrent);
            Cls.AddParameter("@Descripttion", obj.Descripttion);
            return Cls.ExecuteNonQuery("sp_UserPermisstion_Update");
        }
        public static bool Delete(EtUserPermisstion obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", obj.Id);
            return Cls.ExecuteNonQuery("sp_UserPermisstion_Del");
        }
        #endregion
    }

    public class EtUserPermisstion
    {
        public int Id { get; set; }
        public int ModulesMainId { get; set; }
        public int ModulesParentId { get; set; }
        public int GroupId { get; set; }
        public int PermisstionNumber { get; set; }
        public bool IsbtnView { get; set; }
        public bool IsbtnAddNew { get; set; }
        public bool IsbtnEdit { get; set; }
        public bool IsbtnDelete { get; set; }
        public bool IsbtnReview { get; set; }
        public bool IsbtnCancel { get; set; }
        public bool IsbtnPrint { get; set; }
        public bool IsPageMain { get; set; }
        public bool IsPageParrent { get; set; }
        public string Descripttion { get; set; }
    }
}
